
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
<link href="css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="lib/icheck/icheck.css" rel="stylesheet" type="text/css" />
<link href="lib/Hui-iconfont/1.0.6/iconfont.css" rel="stylesheet"
	type="text/css" />
<link href="lib/webuploader/0.1.5/webuploader.css" rel="stylesheet"
	type="text/css" />
<link href="css/common.css" rel="stylesheet" type="text/css" />
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>新增商户</title>
</head>
<body>
	<div class="pd-20">
		<form action="<%=path%>/backstage/shop-add" method="post"
			class="form form-horizontal" id="form-shop-add">
			<input type="hidden" id="id" name="id" value='${shop.cId}' />
			<c:forEach items="${imageList}" var="image" varStatus="varStatus">
				<input type='hidden' id="${image}" name='detailPic' value='${image}'>
			</c:forEach>
			<c:forEach items="${imageList1}" var="image" varStatus="varStatus">
				<input type='hidden' id="${image}" name='detailPic1'
					value='${image}'>
			</c:forEach>
			<div class="cl">店铺信息</div>

			<div class="row cl row_top">
				<label class="form-label col-2"><span class="c-red">*</span>商家名称：</label>
				<div class="formControls col-4">
					<input type="text" class="input-text" value="${shop.cSname}"
						placeholder="" id="" name="c_sname" datatype="*" nullmsg="不能为空"
						style="width: 90%">
				</div>
			</div>
			<div class="row c1">
				<label class="form-label col-2"><span class="c-red">*</span>商家地址：</label>
				<div class="formControls col-6">
					<input type="text" class="input-text" value="${shop.cAddress}"
						placeholder="" id="" name="c_address" datatype="*" nullmsg="不能为空"
						style="width: 90%">
				</div>
			</div>
			<div class="row c1">
				<label class="form-label col-2"><span class="c-red">*</span>经纬度：</label>
				<div class="formControls col-4">
					<input type="text" name="jwd" id="jwd" placeholder=""
						value='<c:if test="${not empty shop.latitude}">${shop.latitude},${shop.longitude}</c:if>'
						class="input-text" style="width: 90%">
				</div>
				<div class="formControls col-4">
					示例： 31.2148,121.4224 &nbsp;&nbsp;&nbsp;&nbsp;<a
						href="http://www.gpsspg.com/maps.htm" target="_blank">经纬度查询</a>
				</div>
			</div>
			<div style="position: absolute; right: 10px; top: 155px;">

				<c:if test="${!empty shop.cLogo }">
					<label class="form-label col-2"></label>
					<div id="i" class="formControls col-10"
						style="position: absolute; right: 105px; top: -78px; width: 100px; height: 100px;">
						<img src="<%=imagePath%>${shop.cLogo}" height="100" width="100"
							border="0" />
					</div>
				</c:if>

				<div class="row cl">
					<label class="form-label col-2"></label>
					<div class="formControls col-10">
						<div class="uploader-thum-container">
							<div id="fileList1"
								style="position: absolute; right: 100px; top: -97px; width: 100px; height: 100px;"
								class="uploader-list"></div>
							<div id="filePicker1"
								style="position: absolute; right: 280px; top: -97px;">
								<span class="c-red">*</span>LOGO
							</div>
							<button style="display: none;" id="btn-star" type="button"
								class="btn btn-default btn-uploadstar radius ml-10">开始上传</button>
						</div>
					</div>
					<input type="hidden" id="image3" name="c_logo"
						value="${shop.cLogo}" />
				</div>

			</div>

			<div class="cl">账户信息</div>
			<div class="row cl row_top">
				<label class="form-label col-2"><span class="c-red">*</span>账户(手机号)：</label>
				<div class="formControls col-2">
					<input type="text" name="c_uname" num="" datatype="*" nullmsg="请填写"
						id="cuname" <c:if test="${not empty shop.cId}">readonly</c:if>
						placeholder="" value="${shop.cUname}" class="input-text"
						style="width: 90%">
				</div>
				<label class="form-label col-2"><span class="c-red">*</span>密码：</label>
				<div class="formControls col-2">
					<input type="text" name="c_pass" type="password" datatype="*"
						nullmsg="请填写" id=""
						<c:if test="${not empty shop.cPass}">readonly</c:if>
						placeholder=""
						value='<c:if test="${not empty shop.cPass}">******</c:if>'
						class="input-text" style="width: 90%">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-2"><span class="c-red">*</span>联系人：</label>
				<div class="formControls col-2">
					<input type="text" name="c_contacts" datatype="*" nullmsg="请填写"
						id="c_contacts" id="" placeholder="" value="${shop.c_contacts}"
						class="input-text" style="width: 90%">
				</div>
			</div>

			<div class="cl">联系方式</div>
			<div class="row cl row_top">
				<label class="form-label col-2"><span class="c-red">*</span>手机号：</label>
				<div class="formControls col-2">
					<input type="text" name="c_mobi" type="text" datatype="*"
						nullmsg="请填写" id="cmobi" placeholder="" value="${shop.cMobi}"
						class="input-text" style="width: 90%">
				</div>
				<label class="form-label col-2">QQ号：</label>
				<div class="formControls col-2">
					<input type="text" name="c_qq" id="" placeholder=""
						value="${shop.cQq}" class="input-text" style="width: 90%">
				</div>
			</div>
			<div class="row c1">
				<label class="form-label col-2">微信号：</label>
				<div class="formControls col-2">
					<input type="text" name="wxid" type="password" id="" placeholder=""
						value="${shop.wxid}" class="input-text" style="width: 90%">
				</div>
				<label class="form-label col-2">邮箱：</label>
				<div class="formControls col-2">
					<input type="text" name="c_mail" id="" placeholder=""
						value="${shop.cMail}" class="input-text" style="width: 90%">
				</div>
			</div>
			<div class="cl">结算账户信息</div>
			<div class="row cl row_top">
				<label class="form-label col-2"><span class="c-red">*</span>开户行名称：</label>
				<div class="formControls col-3">
					<input type="text" name="bankname" datatype="*" nullmsg="请填写" id=""
						placeholder="" value="${shop.bankname}" class="input-text"
						style="width: 90%">
				</div>
				<label class="form-label col-2"><span class="c-red">*</span>提现账号：</label>
				<div class="formControls col-3">
					<input type="text" class="input-text" datatype="*"
						value="${shop.bankno}" placeholder="" id="" name="bankno"
						style="width: 90%">
				</div>
			</div>
			<div class="row c1">
				<label class="form-label col-2"><span class="c-red">*</span>开户行户主：</label>
				<div class="formControls col-3">
					<input type="text" name="acceptname" datatype="*" nullmsg="请填写"
						id="" placeholder="" value="${shop.acceptname}" class="input-text"
						style="width: 90%">
				</div>
				<label class="form-label col-2"><span class="c-red">*</span>身份证号：</label>
				<div class="formControls col-3">
					<input type="text" name="personid" type="text" datatype="*"
						nullmsg="请填写" id="" placeholder="" value="${shop.personid}"
						class="input-text" style="width: 90%">
				</div>
			</div>
			<div class="cl">店铺设置</div>

			<div class="row cl row_top">

				<label class="form-label col-2"><span class="c-red">*</span>是否自营：</label>
				<div class="formControls col-4 skin-minimal">
					<div class="radio-box">
						<input type="radio" name="isziying" datatype="*" nullmsg="请选择！"
							value="0" checked="true"
							<c:if test='${0==shop.is_ziying}'>checked="true"</c:if>>
						<label for="sex-1">否</label>
					</div>
					<div class="radio-box">
						<input type="radio" name="isziying" datatype="*" nullmsg="请选择！"
							value="1" <c:if test='${1==shop.is_ziying}'>checked="true"</c:if>>
						<label for="sex-2">是</label>
					</div>
				</div>
				<label class="form-label col-2"><span class="c-red">*</span>是否打样：</label>
				<div class="formControls col-4 skin-minimal">
					<div class="radio-box">
						<input type="radio" name="is_open" value="1" checked="true"
							<c:if test='${1==shop.is_open}'>checked="true"</c:if>> <label
							for="sex-1">否</label>
					</div>
					<div class="radio-box">
						<input type="radio" name="is_open" value="0"
							<c:if test='${0==shop.is_open}'>checked="true"</c:if>> <label
							for="sex-2">是</label>
					</div>
				</div>

			</div>

			<div class="row c1">
				<label class="form-label col-2"><span class="c-red">*</span>是否下架店铺：</label>
				<div class="formControls col-2">
					<div class="radio-box">
						<input type="radio" id="out-1" name="is_out" datatype="*"
							nullmsg="请选择！" value="0"
							<c:if test='${1!=shop.is_out}'>checked="checked"</c:if>>
						<label for="out-1">否</label>
					</div>
					<div class="radio-box">
						<input type="radio" id="out-2" name="is_out" datatype="*"
							nullmsg="请选择！" value="1"
							<c:if test='${1==shop.is_out}'>checked="checked"</c:if>>
						<label for="out-2">是</label>
					</div>
				</div>

				<label class="form-label col-2"><span class="c-red">*</span>重点商家排序：</label>
				<div class="formControls col-2">
					<input type="text" class="input-text" datatype="n"
						errormsg="请写正确的排序值" value="${empty shop.sort ? 999 : shop.sort}"
						placeholder="" id="sort" name="sort">
				</div>
				(999默认非重点商家,排序值1,2,3...)
			</div>

			<div class="row c1">
				<label class="form-label col-2">所在县市：</label>
				<div class="formControls col-2">
					<span class="select-box"> <select onchange="cityChange()"
						name="c_city_id" class="select" datatype="n" nullmsg="请选择县市">
							<c:forEach items="${citys}" var="city">
								<option value="${city.id}"
									<c:if test="${city.id==shop.c_city_id}">selected</c:if>>${city.name}</option>
							</c:forEach>
					</select>
					</span>
				</div>
				<label class="form-label col-2"><span class="c-red">*</span>所属品类：</label>
				<input type="hidden" class="input-text" value="${shop.cType }"
					placeholder="" id="ctype" name="c_type" style="width: 90%">
				<div class="formControls col-2">
					<span class="select-box"> <select class="select" id="type1"
						onchange="firstChange(this);">
							<option value="">--大类--</option>
							<!-- <option <c:if test="${bigtype==-1}">selected</c:if> value="-1">自营</option> -->
							<c:forEach items="${types}" var="type">
								<option value="${type.cCode}"
									<c:if test="${bigtype==type.cCode}">selected</c:if>>${type.cName}</option>
							</c:forEach>
					</select>
					</span>
				</div>
				<div id="twotype" style="display: none;" class="formControls col-2">
					<span class="select-box"> <select class="select" id="type2"
						onchange="secondChange(this);" onclick="secondClick(this)">
							<option value="">--中类--</option>
							<%-- <c:forEach items="${types2}" var="type">
					<option value="${type.cCode}" <c:if test="${type.cCode==stype}">selected</c:if> >${type.cName}${type.cCode}</option>
					</c:forEach> --%>
					</select>
					</span>
				</div>
				 &nbsp;&nbsp;(选择非自营二级品类)
			</div>
			<div class="row c1">
				<label class="form-label col-2"><span class="c-red">*</span>结算方式：</label>
				<div class="formControls col-2">
					<span class="select-box"> <select name="balance"
						class="select" datatype="*" nullmsg="请选择结算方式">
							<option <c:if test="${shop.balance=='预付' }">selected</c:if>
								value="预付">预付</option>
							<option <c:if test="${shop.balance=='现结算' }">selected</c:if>
								value="现结算">现结算</option>
							<option <c:if test="${shop.balance=='周结算' }">selected</c:if>
								value="周结算">周结算</option>
							<option <c:if test="${shop.balance=='月结算' }">selected</c:if>
								value="月结算">月结算</option>
					</select>
					</span>
				</div>
				<label class="form-label col-2"><span class="c-red">*</span>佣金比例：</label>
				<div class="formControls col-2">
					<input type="text" name="discount" id="discount" placeholder=""
						datatype="*" nullmsg="不能为空" value="${shop.discount}"
						class="input-text">
				</div>
				<p style="line-height: 31px;">%&nbsp;&nbsp;&nbsp;&nbsp;示例：30%
					输入30</p>
			</div>
			<div class="row c1">
				<label class="form-label col-2"><span class="c-red">*</span>人均消费：</label>
				<div class="formControls col-2">
					<input type="text" name="c_fee" datatype="n" nullmsg="请填写" id=""
						placeholder="" value="${shop.cFee}" class="input-text"
						style="width: 80%"> 元
				</div>
				<label class="form-label col-2"><span class="c-red">*</span>配送费：</label>
				<div class="formControls col-2">
					<input type="text" name="c_psf" datatype="n" nullmsg="请填写" id=""
						placeholder="" value="${shop.cPsf}" class="input-text"
						style="width: 80%"> 元
				</div>
			</div>
			<div class="row c1">
				<label class="form-label col-2"><span class="c-red">*</span>起送费：</label>
				<div class="formControls col-2">
					<input type="text" name="start_fee" datatype="n" nullmsg="请填写"
						id="" placeholder="" value="${shop.start_fee}" class="input-text"
						style="width: 80%"> 元
				</div>
				<label class="form-label col-2"><span class="c-red">*</span>平均配送时间：</label>
				<div class="formControls col-2">
					<input type="text" name="average_shipping_time" datatype="n"
						nullmsg="请填写" id="" placeholder=""
						value="${shop.average_shipping_time}" class="input-text"
						style="width: 80%"> 分钟
				</div>
			</div>
			<div class="row c1">
				<label class="form-label col-2"><span class="c-red">*</span>是否启用餐盒费：</label>
				<div class="formControls col-2">
					<div class="radio-box">
						<input type="radio" name="is_lunchbox" datatype="*" nullmsg="请选择！"
							value="0" checked="true"
							<c:if test='${0==shop.is_lunchbox}'>checked="true"</c:if>>
						<label for="sex-1">否</label>
					</div>
					<div class="radio-box">
						<input type="radio" name="is_lunchbox" datatype="*" nullmsg="请选择！"
							value="1"
							<c:if test='${1==shop.is_lunchbox}'>checked="true"</c:if>>
						<label for="sex-2">是</label>
					</div>
				</div>
				<label class="form-label col-2"><span class="c-red">*</span>餐盒费单价：</label>
				<div class="formControls col-2">
					<input type="text" name="lunchbox_price" datatype="/^[\d\.]+$/"
						nullmsg="请填写" id="" placeholder="" value="${shop.lunchbox_price}"
						class="input-text" style="width: 80%"> 元
				</div>
			</div>
			<div class="row c1">
				<label class="form-label col-2"><span class="c-red">*</span>是否结算餐盒费给商家：</label>
				<div class="formControls col-2 skin-minimal">
					<div class="radio-box">
						<input type="radio" name="is_recieve_box_money" datatype="*"
							nullmsg="请选择！" id="box1" value="2"
							<c:if test='${2==shop.is_recieve_box_money}'>checked="checked"</c:if>>
						<label for="box1">否</label>
					</div>
					<div class="radio-box">
						<input type="radio" name="is_recieve_box_money" datatype="*"
							nullmsg="请选择！" id="box2" value="1"
							<c:if test='${1==shop.is_recieve_box_money || empty shop.is_recieve_box_money || shop.is_recieve_box_money == 0 }'>checked="checked"</c:if>>
						<label for="box2">是</label>
					</div>
				</div>
			</div>

			<div class="row cl">
				<label class="form-label col-2">广告语：</label>
				<div class="formControls col-10">
					<input type="text" name="c_ad" id="" placeholder=""
						value="${shop.cAd}" class="input-text">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-2">简介：</label>
				<div class="formControls col-10">
					<textarea name="c_des" cols="" rows="" class="textarea"
						placeholder="说点什么...最少输入10个字符" dragonfly="true"
						onKeyUp="textarealength(this,200)">${shop.cDes}</textarea>
					<p class="textarea-numberbar">
						<em class="textarea-length">0</em>/200
					</p>
				</div>
			</div>
			<!-- <div class="row cl" style="display:none;">

		  <label class="form-label col-2"><span class="c-red">*</span>是否营业：</label>
		  <div class="formControls col-2 skin-minimal">
			<div class="radio-box">
			  <input type="radio"  name="is_open" datatype="*" nullmsg="请选择！" value="1" checked="true" >
			  <label for="sex-2">营业</label>
			</div>
		  </div>
		</div> -->

			<%-- <div class="row cl">
			<label class="form-label col-2"></label><div class="formControls col-10">
			<c:if test="${!empty shop.image3 }">
			<img id="imgthree" src="<%=imagePath%>${shop.image3}" height="100" border="0" />
			</c:if>
		</div> --%>

			<button onClick="shop_save_submit();" id="save-btn"
				class="btn btn-primary radius" type="submit" style="display: none;">
				<i class="Hui-iconfont">&#xe632;</i> 保存并提交审核
			</button>
		</form>
		<div class="mt-20">
			<div class="row cl">
				<label class="form-label col-2 text-r">商家资质（用户可见）：</label>
				<div class="uploaded f-l col-10" id="uploaded">
					<ul class="file-con" id="file-con1">
						<!-- detailPics 商品详情 -->
						<c:forEach items="${imageList1}" var="image" varStatus="varStatus">

							<li class="f-l pic-con mr-10"><img
								src='<%=imagePath%>${image}'><br />
								<button data-url='${image}' onclick="deleteUnSavePic(this);"
									class="btn btn-primary radius" type="button">删除</button></li>

						</c:forEach>
					</ul>
					<div class="cl"></div>
				</div>
				<div class="cl"></div>
				<label class="form-label col-2 mt-10"></label>
				<form onsubmit="return false;"
					action="<%=path%>/backstage/shop-logo-upload" method="post"
					id="fileForm1" enctype="multipart/form-data">
					<div class="formControls col-10 mt-10">
						<span class="btn-upload"> <a href="javascript:void();"
							class="btn btn-primary radius">浏览文件</a> <input type="file"
							id="fileSelect1" name="file" class="input-file"
							onchange="fileChange1(this)">
						</span>
					</div>
				</form>
			</div>
		</div>
		<div class="mt-20">
			<div class="row cl">
				<label class="form-label col-2 text-r">商家证件（用户不可见）：</label>
				<div class="uploaded f-l col-10" id="uploaded">
					<ul class="file-con" id="file-con">
						<!-- detailPics 商品详情 -->
						<c:forEach items="${imageList}" var="image" varStatus="varStatus">

							<li class="f-l pic-con mr-10"><img
								src='<%=imagePath%>${image}'><br />
								<button data-url='${image}' onclick="deleteUnSavePic(this);"
									class="btn btn-primary radius" type="button">删除</button></li>

						</c:forEach>
					</ul>
					<div class="cl"></div>
				</div>
				<div class="cl"></div>
				<label class="form-label col-2 mt-10"></label>
				<form onsubmit="return false;"
					action="<%=path%>/backstage/shop-logo-upload" method="post"
					id="fileForm" enctype="multipart/form-data">
					<div class="formControls col-10 mt-10">
						<span class="btn-upload"> <a href="javascript:void();"
							class="btn btn-primary radius">浏览文件</a> <input type="file"
							id="fileSelect" name="file" class="input-file"
							onchange="fileChange(this)">
						</span>
					</div>
				</form>
			</div>

			<div class="row cl mt-20">
				<div class="col-10 col-offset-2">
					<button onClick="shop_save();" id="goods-btn"
						class="btn btn-primary radius" type="button">
						<i class="Hui-iconfont">&#xe632;</i> 保存并提交审核
					</button>
					<button onClick="layer_close();" class="btn btn-default radius"
						type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
				</div>
			</div>
		</div>
		<input id="btype" type="hidden" value="${bigtype }" /> <input
			id="stype" type="hidden" value="${stype }" /> <input id="waimai"
			type="hidden" value="${waimai }" /> <input id="xiandan"
			type="hidden" value="${xiandan }" /> <input id="shfw" type="hidden"
			value="${shfw }" />
	</div>
	<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
	<script type="text/javascript" src="lib/layer/2.1/layer.js"></script>
	<script type="text/javascript" src="lib/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript" src="lib/icheck/jquery.icheck.min.js"></script>
	<script type="text/javascript"
		src="lib/Validform/5.3.2/Validform.min.js"></script>
	<script type="text/javascript"
		src="lib/webuploader/0.1.5/webuploader.min.js"></script>
	<script type="text/javascript"
		src="lib/ueditor/1.4.3/ueditor.config.js"></script>
	<script type="text/javascript"
		src="lib/ueditor/1.4.3/ueditor.all.min.js"> </script>
	<script type="text/javascript"
		src="lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
	<script type="text/javascript" src="js/H-ui.js"></script>
	<script type="text/javascript" src="js/H-ui.admin.js"></script>
	<script type="text/javascript" src="js/jquery.form.js"></script>
	<script type="text/javascript">

$(function(){
	//$("#lunchbox_price").val("0.0");
	
	$("#cmobi").focus(function(){
		if($("#cmobi").val()==""){
			$(this).val($("#cuname").val());
		}
	});
	$("#cuname").blur(function(){
		var cuname=$(this).val();
		if(cuname!=""&&!$("#cuname").prop("readonly")){
			$.ajax({
				type:"post",
				url:"<%=path%>/backstage/shop-name-re",
				data : {name:cuname},
				success : function(msg){
					if(msg==1){
						$("#cuname").attr({"num":"1"});
					}else{
						$("#cuname").attr({"num":msg});
					}
				}
			});
		}
	});
	
	if($("#btype").val()!=""){
		firstChange(document.getElementById("type1"));
	}
	
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	
	// 优化retina, 在retina下这个值是2
	ratio = window.devicePixelRatio || 1,
	// 缩略图大小
	thumbnailWidth = 110 * ratio,
	thumbnailHeight = 110 * ratio,
	$list = $("#fileList"),
	$btn = $("#btn-star"),
	state = "pending",
	uploader1;



	var uploader1 = WebUploader.create({
		auto: true,
		swf: 'lib/webuploader/0.1.5/Uploader.swf',
	
		// 文件接收服务端。
		server: '<%=path%>/backstage/shop-logo-upload',
	
		// 选择文件的按钮。可选。
		// 内部根据当前运行是创建，可能是input元素，也可能是flash.
		pick: '#filePicker',
	
		// 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
		resize: false,
		// 只允许选择图片文件。
		accept: {
			title: 'Images',
			extensions: 'gif,jpg,jpeg,bmp,png',
			mimeTypes: 'image/*'
		}
	});
	uploader1.on( 'fileQueued', function( file ) {
		var $li = $(
			'<div id="' + file.id + '" class="item">' +
				'<div class="pic-box"><img></div>'+
				'<div class="info">' + file.name + '</div>' +
				'<p class="state">等待上传...</p>'+
			'</div>'
		),
		$img = $li.find('img');
		$list.append( $li );
	
		// 创建缩略图
		// 如果为非图片文件，可以不用调用此方法。
		// thumbnailWidth x thumbnailHeight 为 100 x 100
		uploader1.makeThumb( file, function( error, src ) {
			if ( error ) {
				$img.replaceWith('<span>不能预览</span>');
				return;
			}
	
			$img.attr( 'src', src );
		}, thumbnailWidth, thumbnailHeight );
	});
	// 文件上传过程中创建进度条实时显示。
	uploader1.on( 'uploadProgress', function( file, percentage ) {
		var $li = $( '#'+file.id ),
			$percent = $li.find('.progress-box .sr-only');
	
		// 避免重复创建
		if ( !$percent.length ) {
			$percent = $('<div class="progress-box"><span class="progress-bar radius"><span class="sr-only" style="width:0%"></span></span></div>').appendTo( $li ).find('.sr-only');
		}
		$li.find(".state").text("上传中");
		$percent.css( 'width', percentage * 100 + '%' );
	});
	
	// 文件上传成功，给item添加成功class, 用样式标记上传成功。
	uploader1.on( 'uploadSuccess', function( file, response ) {
		$( '#'+file.id ).addClass('upload-state-success').find(".state").text("已上传");
		$("#c_logo").val(response.datas);
		$("#imgthree").hide();
	});
	
	// 文件上传失败，显示上传出错。
	uploader1.on( 'uploadError', function( file ) {
		$( '#'+file.id ).addClass('upload-state-error').find(".state").text("上传出错");
	});
	
	// 完成上传完了，成功或者失败，先删除进度条。
	uploader1.on( 'uploadComplete', function( file ) {
		$( '#'+file.id ).find('.progress-box').fadeOut();
	});
	uploader1.on('all', function (type) {
        if (type === 'startUpload') {
            state = 'uploading';
        } else if (type === 'stopUpload') {
            state = 'paused';
        } else if (type === 'uploadFinished') {
            state = 'done';
        }

        if (state === 'uploading') {
            $btn.text('暂停上传');
        } else {
            $btn.text('开始上传');
        }
    });

    $btn.on('click', function () {
        if (state === 'uploading') {
            uploader1.stop();
        } else {
            uploader1.upload();
        }
    });

});

$(function(){

	$list1 = $("#fileList1"),
	$btn1 = $("#btn-star1"),
	state = "pending",
	uploader2;

	var uploader2 = WebUploader.create({
		auto: true,
		swf: 'lib/webuploader/0.1.5/Uploader.swf',
	
		// 文件接收服务端。
		server: '<%=path%>/backstage/shop-logo-upload',
	
		// 选择文件的按钮。可选。
		// 内部根据当前运行是创建，可能是input元素，也可能是flash.
		pick: '#filePicker1',
	
		// 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
		resize: false,
		// 只允许选择图片文件。
		accept: {
			title: 'Images',
			extensions: 'gif,jpg,jpeg,bmp,png',
			mimeTypes: 'image/*'
		}
	});
	uploader2.on( 'fileQueued', function( file ) {
		var $li = $(
			'<div id="' + file.id + '" class="item">' +
				'<div class="pic-box"><img></div>'+
				'<div class="info">' + file.name + '</div>' +
				'<p class="state">等待上传...</p>'+
			'</div>'
		),
		$img = $li.find('img');
		$list1.append( $li );
	
		// 创建缩略图
		// 如果为非图片文件，可以不用调用此方法。
		// thumbnailWidth x thumbnailHeight 为 100 x 100
		uploader2.makeThumb( file, function( error, src ) {
			if ( error ) {
				$img.replaceWith('<span>不能预览</span>');
				return;
			}
	
			$img.attr( 'src', src );
		}, thumbnailWidth, thumbnailHeight );
	});
	// 文件上传过程中创建进度条实时显示。
	uploader2.on( 'uploadProgress', function( file, percentage ) {
		var $li = $( '#'+file.id ),
			$percent = $li.find('.progress-box .sr-only');
	
		// 避免重复创建
		if ( !$percent.length ) {
			$percent = $('<div class="progress-box"><span class="progress-bar radius"><span class="sr-only" style="width:0%"></span></span></div>').appendTo( $li ).find('.sr-only');
		}
		$li.find(".state").text("上传中");
		$percent.css( 'width', percentage * 100 + '%' );
	});
	
	// 文件上传成功，给item添加成功class, 用样式标记上传成功。
	uploader2.on( 'uploadSuccess', function( file, response ) {
		$('#'+file.id).addClass('upload-state-success').find(".state").text("");
		//$('#fileList1 .info').hidden();
		$("#image3").val(response.datas);
		//$("#i").css({"display":"none"});
	});
	
	// 文件上传失败，显示上传出错。
	uploader2.on( 'uploadError', function( file ) {
		$( '#'+file.id ).addClass('upload-state-error').find(".state").text("上传出错");
	});
	
	// 完成上传完了，成功或者失败，先删除进度条。
	uploader2.on( 'uploadComplete', function( file ) {
		$( '#'+file.id ).find('.progress-box').fadeOut();
		//$( '#'+file.id ).find('.info').fadeOut();
	});
	uploader2.on('all', function (type) {
        if (type === 'startUpload') {
            state = 'uploading';
        } else if (type === 'stopUpload') {
            state = 'paused';
        } else if (type === 'uploadFinished') {
            state = 'done';
        }

        if (state === 'uploading') {
            $btn1.text('暂停上传');
        } else {
            $btn1.text('开始上传');
        }
    });

    $btn1.on('click', function () {
        if (state === 'uploading') {
            uploader2.stop();
        } else {
            uploader2.upload();
        }
    });

});

$(function(){

	$list2 = $("#fileList2"),
	$btn2 = $("#btn-star2"),
	state = "pending",
	uploader2;

	var uploader2 = WebUploader.create({
		auto: true,
		swf: 'lib/webuploader/0.1.5/Uploader.swf',
	
		// 文件接收服务端。
		server: '<%=path%>/backstage/shop-logo-upload',
	
		// 选择文件的按钮。可选。
		// 内部根据当前运行是创建，可能是input元素，也可能是flash.
		pick: '#filePicker2',
	
		// 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
		resize: false,
		// 只允许选择图片文件。
		accept: {
			title: 'Images',
			extensions: 'gif,jpg,jpeg,bmp,png',
			mimeTypes: 'image/*'
		}
	});
	uploader2.on( 'fileQueued', function( file ) {
		var $li = $(
			'<div id="' + file.id + '" class="item">' +
				'<div class="pic-box"><img></div>'+
				'<div class="info">' + file.name + '</div>' +
				'<p class="state">等待上传...</p>'+
			'</div>'
		),
		$img = $li.find('img');
		$list2.append( $li );
	
		// 创建缩略图
		// 如果为非图片文件，可以不用调用此方法。
		// thumbnailWidth x thumbnailHeight 为 100 x 100
		uploader2.makeThumb( file, function( error, src ) {
			if ( error ) {
				$img.replaceWith('<span>不能预览</span>');
				return;
			}
	
			$img.attr( 'src', src );
		}, thumbnailWidth, thumbnailHeight );
	});
	// 文件上传过程中创建进度条实时显示。
	uploader2.on( 'uploadProgress', function( file, percentage ) {
		var $li = $( '#'+file.id ),
			$percent = $li.find('.progress-box .sr-only');
	
		// 避免重复创建
		if ( !$percent.length ) {
			$percent = $('<div class="progress-box"><span class="progress-bar radius"><span class="sr-only" style="width:0%"></span></span></div>').appendTo( $li ).find('.sr-only');
		}
		$li.find(".state").text("上传中");
		$percent.css( 'width', percentage * 100 + '%' );
	});
	
	// 文件上传成功，给item添加成功class, 用样式标记上传成功。
	uploader2.on( 'uploadSuccess', function( file, response ) {
		$('#'+file.id).addClass('upload-state-success').find(".state").text("");
		//$('#fileList1 .info').hidden();
		$("#image3").val(response.datas);
		//$("#i").css({"display":"none"});
	});
	
	// 文件上传失败，显示上传出错。
	uploader2.on( 'uploadError', function( file ) {
		$( '#'+file.id ).addClass('upload-state-error').find(".state").text("上传出错");
	});
	
	// 完成上传完了，成功或者失败，先删除进度条。
	uploader2.on( 'uploadComplete', function( file ) {
		$( '#'+file.id ).find('.progress-box').fadeOut();
		//$( '#'+file.id ).find('.info').fadeOut();
	});
	uploader2.on('all', function (type) {
        if (type === 'startUpload') {
            state = 'uploading';
        } else if (type === 'stopUpload') {
            state = 'paused';
        } else if (type === 'uploadFinished') {
            state = 'done';
        }

        if (state === 'uploading') {
            $btn2.text('暂停上传');
        } else {
            $btn2.text('开始上传');
        }
    });

    $btn2.on('click', function () {
        if (state === 'uploading') {
            uploader2.stop();
        } else {
            uploader2.upload();
        }
    });

});
function shop_save_submit(){
	$("#form-shop-add").Validform({
		tiptype:2,
		ajaxPost:true,
		beforeSubmit:function(form){
			if($("#cuname").attr("num")==1){
				alert("账户名已注册");
				return false;
			}
			if($("#image3").val().length<3){
				alert("请上传LOGO");
				return false;
			}
			if($("#ctype").val().length<1){
				alert("请选择分类");
				return false;
			}
			var re= /^\d+\.\d+,\d+\.\d+$/;
			if(!re.test($("#jwd").val())){
				alert("请填写正确的经纬度");
				return false;
			}
			var discount=$("#discount").val();
			if(discount>100||discount<0){
				alert("请填写正确的佣金比例");
				return false;
			}
		},
		callback:function(form){
			var index = parent.layer.getFrameIndex(window.name);
			if (index){//关闭弹出层
				parent.$('.btn-refresh').click(); 
				parent.layer.close(index);
			}else{//单独的页面
				location.href = "<%=path%>/backstage/shop-list"; 
			}
		}
	});
}

var type1;
var type2;
function firstChange(theSelect){
	var typeId = theSelect.value;
	var waimai=$("#waimai").val();
	var xiandan=$("#xiandan").val();
	var shfw=$("#shfw").val();
	$("#ctype").val(typeId);
	if(typeId==waimai||typeId==xiandan||typeId==shfw){
		$("#ctype").val("");
		$("#twotype").css({"display":"block"});
		$.ajax({
			type:"post",
			async:false,
			url:"<%=path%>/backstage/get-types-chil",
			data : {typeid:typeId},
			success : function(msg){
				type2 = msg;
			}
		});
	var options = "<option value=''>--中类--</option>";
	for (var i = 0; i < type2.length; i++){
		if (typeId == type2[i].cBelong){
			var aOption;
			if($("#stype").val()==type2[i].cCode){
				aOption = "<option selected value='"+type2[i].cCode+"' >"+type2[i].cName+"</option>";
				$("#ctype").val(type2[i].cCode);
			}else{
				aOption = "<option value='"+type2[i].cCode+"' >"+type2[i].cName+"</option>";
			}
			options += aOption;
		}
	}
	$("#type2").html(options);
	}else{
		$("#twotype").css({"display":"none"});
	}
}
function secondChange(theSelect){
	var typeId = theSelect.value;
	$("#ctype").val(typeId);
}
function cityChange(){
	$("#type1").val("");
	$("#twotype").css({"display":"none"});
	$("#ctype").val("");
}
function delImage(obj){
	$(obj).parent().parent().remove();
	var imgs="";
	$(".pic").each(function(){
		imgs+=$(this).attr("name")+",";
	});
	$("#image_list").val(imgs);
}
var fileUploadOptions = {
		success:fileUploadSuccess,
		dataType:'json', 
		uploadProgress:onProgress,
		beforeSubmit:beforeSubmit,
		};
function beforeSubmit(){
	//alert("fdasf");
}
function onProgress(event,position ,total ,percentComplete ){
	//console.log(position + ">>>>>>>");
}
var rootPath  =  '<%=imagePath%>';
		function fileUploadSuccess(responseText) {
			var img = "<li class='f-l pic-con mr-10'><img  src='"+rootPath+responseText.datas+"'><br/><button data-url='"
					+ responseText.datas
					+ "' onclick='deleteUnSavePic(this);' class='btn btn-primary radius' type='button'>删除</button></li>";
			$("#file-con").append(img);
			var hiddenFile = "<input type='hidden' name='detailPic' value='"+responseText.datas+"'>";
			$("#form-shop-add").append(hiddenFile);
			layer.closeAll();
		}

		function fileChange(inputForm) {
			layer.load();
			$("#fileForm").ajaxSubmit(fileUploadOptions);
		}
		//删除未保存到商品详情里的图片 
		function deleteUnSavePic(btn) {
			var imgUrl = $(btn).attr("data-url");
			$(btn).parent("li").remove();
			$("input[value='" + imgUrl + "']").remove();
		}

		var fileUploadOptions1 = {
			success : fileUploadSuccess1,
			dataType : 'json',
			uploadProgress : onProgress1,
			beforeSubmit : beforeSubmit1,
		};
		function beforeSubmit1() {
			//alert("fdasf");
		}
		function onProgress1(event, position, total, percentComplete) {
			//console.log(position + ">>>>>>>");
		}
		function fileUploadSuccess1(responseText) {
			var img = "<li class='f-l pic-con mr-10'><img  src='"+rootPath+responseText.datas+"'><br/><button data-url='"
					+ responseText.datas
					+ "' onclick='deleteUnSavePic(this);' class='btn btn-primary radius' type='button'>删除</button></li>";
			$("#file-con1").append(img);
			var hiddenFile = "<input type='hidden' name='detailPic1' value='"+responseText.datas+"'>";
			$("#form-shop-add").append(hiddenFile);
			layer.closeAll();
		}

		function fileChange1(inputForm) {
			layer.load();
			$("#fileForm1").ajaxSubmit(fileUploadOptions1);
		}
		function shop_save() {
			$("#save-btn").click();
		}
	</script>
</body>
</html>